package cn.wikiflyer.beikang.view;

import cn.wikiflyer.beikang.R;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

/**订单状态
 */
public class StatusView extends TextView {

	public StatusView(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	public StatusView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public StatusView(Context context) {
		super(context);
	}
	/**设置状态 0立即付款、1配送中、2订单完成
	 */
	public void setStatus(final int status){
		switch (status) {
		case 0:
			this.setText("立即付款");
			this.setBackgroundResource(R.drawable.status_bg1);
			this.setTextColor(getResources().getColor(R.color.status_1));
			break;
		case 1:
			this.setText("配送中");
			this.setBackgroundResource(R.drawable.status_bg2);
			this.setTextColor(getResources().getColor(R.color.status_2));
			break;
		default:
			this.setText("订单完成");
			this.setBackgroundResource(R.drawable.status_bg3);
			this.setTextColor(getResources().getColor(R.color.status_3));
			break;
		}
		this.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				mStatusOnClickListener.click(status);
			}
		});
	}
	private StatusOnClickListener mStatusOnClickListener;
	public void setClickListener(StatusOnClickListener mListener){
		this.mStatusOnClickListener = mListener;
	}
	/**点击触发事件
	 */
	public interface StatusOnClickListener{
		public void click(int status);
	}

}
